using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for clsProduct
/// </summary>
public class clsProduct
{
    
    public DataTable getlistProduct(int catID)
    {
        DBconnect connet = new DBconnect();
        connet.Open();
        if (connet.IsConnected == false)
            return null;
        DataTable tmp = new DataTable();     
        string sql = "SELECT p.ID as ID, a.ID as aID, p.description, p.image_url,p.name, a.time_expire, a.current_rate FROM products p INNER JOIN auction_sale a ON p.ID = a.products_id WHERE p.categories_id = " + catID;
        tmp = connet.GetDataTable(sql);
        connet.Close();
        return tmp;
    }
    public int countCustomer(int auctionID)
    {
        DBconnect connet = new DBconnect();
        connet.Open();
        if (connet.IsConnected == false)
            return -1;

        DataTable tmp = new DataTable();        
        string sql = "SELECT * FROM auction_sale_detail WHERE auction_sale_id = " + auctionID;
        tmp = connet.GetDataTable(sql);
        connet.Close();
        return tmp.Rows.Count;
    }
    public DataTable SearchByName(string name)
    {
        DBconnect connet = new DBconnect();
        connet.Open();
        if (connet.IsConnected == false)
            return null;
        DataTable tmp = new DataTable();
        string sql = "SELECT p.ID as ID, a.ID as aID, p.description, p.image_url,p.name, a.time_expire, a.current_rate FROM products p INNER JOIN auction_sale a ON p.ID = a.products_id Where p.name like '%" + name + "%'";
        tmp = connet.GetDataTable(sql);
        connet.Close();
        return tmp;
    }
}
